import { requestcars, removecars, addToCart } from '@/api'

const actions = {
    mycar(context, value) {
        requestcars().then(function(res) {
            console.log(res.data.data[0].cartInfoList);
            context.commit('MYCAR', res.data.data[0].cartInfoList)
        })
    },
    remove(context, skuId) {
        console.log(skuId);
        removecars(skuId).then(function(res) {
            console.log(res.data);
        })
    },
    changecarnum(context, { skuId, skuNum }) {
        console.log(skuId, skuNum);
        addToCart(skuId, skuNum).then(function(res) {
            console.log(res.data);
        })
    }
}
const mutations = {
    MYCAR(state, value) {
        state.cartInfoList = value

    }
}
const state = {
    cartInfoList: []
}
const getters = {
    cartInfoList(state) {
        return state.cartInfoList
    }
}




export default {
    actions,
    mutations,
    state,
    getters

}